from tornado_swagger.components import components


@components.schemas.register
class OkModel(object):
    """
    ---
    type: object
    description: status ok
    properties:
        status:
            type: integer
            example: 200
        desc:
            type: string
            example: OK
        data:
            type: array
            items:
            example: []
    """


@components.schemas.register
class ErrorModel(object):
    """
    ---
    type: object
    description: status error
    properties:
        status:
            type: integer
            example: 400
        desc:
            type: string
            example: error
        data:
            type: array
            items:
            example: []
    """


@components.schemas.register
class CartInfoModel(object):
    """
    ---
    type: object
    description: status ok
    allOf:
        - $ref: '#/components/schemas/OkModel'
        - type: object
          required:
            - data
          properties:
            data:
              type: array
              items:
                type: object
                properties:
                    id:
                        type: integer
                    username:
                        type: string
                    mobile:
                        type: string
    """


@components.schemas.register
class CartErrorModel(object):
    """
    ---
    type: object
    description: status ok
    allOf:     # Combines the BaseModel and the inline model
        - $ref: '#/components/schemas/OkModel'
        - type: object
          required:
            - data
          properties:
            data:
              type: array
              items:
                type: object
                properties:
                    id:
                        type: integer
                    username:
                        type: string
                    mobile:
                        type: string
    """


@components.schemas.register
class AddressModel:
    """
    ---
    type: object
    description: status ok
    allOf:
        - $ref: '#/components/schemas/OkModel'
        - type: object
          required:
            - data
          properties:
            data:
              type: array
              items:
                type: object
                properties:
                    id:
                        type: integer
                        example: 地址id
                    name:
                        type: string
                        example: 收货人姓名
                    mobile:
                        type: string
                        example: 收货人手机
                    area:
                        type: string
                        example: 收货人地址
                    detail:
                        type: string
                        example: 收货人地址
                    is_default:
                        type: boolean
                        example: 是否默认地址
    """


@components.schemas.register
class UserInfo(object):
    """
    ---
    type: object
    description: status ok
    allOf:
        - $ref: '#/components/schemas/OkModel'
        - type: object
          required:
            - data
          properties:
            data:
              type: array
              items:
                type: object
                properties:
                    id:
                        type: integer
                    username:
                        type: string
                    mobile:
                        type: string
                    icon:
                        type: string
                    cards:
                        type: integer
                    collect:
                        type: integer
                    trace:
                        type: integer
    """
